From: Florian Müllner Date: Thu, 5 Jun 2025 11:22:27 +0000 (+0200) Subject: build: Use build-aux for auxiliary build scripts X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~124^2^2~65 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=cd65221e5495e8de51a05169c762cbd5985df240;p=gnome-shell.git build: Use build-aux for auxiliary build scripts This is the name most projects have settled on, so let's use that as well. Part-of: --- diff --git a/build-aux/check-version.py b/build-aux/check-version.py new file mode 100755 index 000000000..c24ab41b4 --- /dev/null +++ b/build-aux/check-version.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import os, sys +from pathlib import Path +from xml.etree.ElementTree import ElementTree +import argparse + +def check_version(version, file, type='news'): + if type == 'news': + line = file.open().readline() + ok = line.startswith(version) + print("{}: {}".format(file, "OK" if ok else "FAILED")) + if not ok: + raise Exception("{} does not start with {}".format(file, version)) + elif type == 'metainfo': + query = './releases/release[@version="{}"]'.format(version) + ok = ElementTree(file=file).find(query) is not None + print("{}: {}".format(file, "OK" if ok else "FAILED")) + if not ok: + raise Exception("{} does not contain release {}".format(file, version)) + else: + raise Exception('Not implemented') + +parser = argparse.ArgumentParser(description='Check release version information.') +parser.add_argument('--type', choices=['metainfo','news'], default='news') +parser.add_argument('version', help='the version to check for') +parser.add_argument('files', nargs='+', help='files to check') +args = parser.parse_args() + +distroot = os.environ.get('MESON_DIST_ROOT', './') + +try: + for file in args.files: + check_version(args.version, Path(distroot, file), args.type) +except: + sys.exit(1) diff --git a/build-aux/generate-app-list.py b/build-aux/generate-app-list.py new file mode 100755 index 000000000..067c36967 --- /dev/null +++ b/build-aux/generate-app-list.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import argparse + +def read_app_ids(path) -> str: + ids = [] + with open(path, "r") as file: + for line in file: + # strip comments + line, _, _ = line.partition('#'); + line = line.strip() + if len(line) > 0: + ids.append(line) + return ids + +def print_as_array(ids): + mapped_ids = list(map(lambda i: f" '{i}'", ids)) + print('[') + print(',\n'.join(mapped_ids)) + print(']') + +def print_as_pages(ids): + mapped_ids = [] + for i, id in enumerate(ids): + mapped_ids.append(f" '{id}': <{{'position': <{i}>}}>") + + print('[{') + print(',\n'.join(mapped_ids)) + print('}]') + +parser = argparse.ArgumentParser() +parser.add_argument('--pages', action='store_true') +parser.add_argument('file') +args = parser.parse_args() + +ids = read_app_ids(args.file) +if args.pages: + print_as_pages(ids) +else: + print_as_array(ids) diff --git a/build-aux/generate-stylesheets.py b/build-aux/generate-stylesheets.py new file mode 100755 index 000000000..10e65b756 --- /dev/null +++ b/build-aux/generate-stylesheets.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import os +from pathlib import PurePath +import subprocess + +stylesheets = [ + 'data/theme/gnome-shell-high-contrast.css', + 'data/theme/gnome-shell-dark.css', + 'data/theme/gnome-shell-light.css' +] + +sourceroot = os.environ.get('MESON_SOURCE_ROOT') +distroot = os.environ.get('MESON_DIST_ROOT') + +for stylesheet in stylesheets: + stylesheet_path = PurePath(stylesheet) + src = PurePath(sourceroot, stylesheet_path.with_suffix('.scss')) + dst = PurePath(distroot, stylesheet_path) + subprocess.run(['sassc', '-a', src, dst], check=True) diff --git a/meson.build b/meson.build index 94d717f2f..44e984bf9 100644 --- a/meson.build +++ b/meson.build @@ -142,7 +142,7 @@ endif mutter_typelibdir = mutter_dep.get_variable('typelibdir') python = find_program('python3') gjs = find_program('gjs') -generate_app_list = find_program('meson/generate-app-list.py') +generate_app_list = find_program('build-aux/generate-app-list.py') cc = meson.get_compiler('c') @@ -331,8 +331,8 @@ gnome.post_install( gtk_update_icon_cache: true ) -meson.add_dist_script('meson/generate-stylesheets.py') -meson.add_dist_script('meson/check-version.py', meson.project_version(), 'NEWS') +meson.add_dist_script('build-aux/generate-stylesheets.py') +meson.add_dist_script('build-aux/check-version.py', meson.project_version(), 'NEWS') summary_options = { 'x11': have_x11, diff --git a/meson/check-version.py b/meson/check-version.py deleted file mode 100755 index c24ab41b4..000000000 --- a/meson/check-version.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 - -import os, sys -from pathlib import Path -from xml.etree.ElementTree import ElementTree -import argparse - -def check_version(version, file, type='news'): - if type == 'news': - line = file.open().readline() - ok = line.startswith(version) - print("{}: {}".format(file, "OK" if ok else "FAILED")) - if not ok: - raise Exception("{} does not start with {}".format(file, version)) - elif type == 'metainfo': - query = './releases/release[@version="{}"]'.format(version) - ok = ElementTree(file=file).find(query) is not None - print("{}: {}".format(file, "OK" if ok else "FAILED")) - if not ok: - raise Exception("{} does not contain release {}".format(file, version)) - else: - raise Exception('Not implemented') - -parser = argparse.ArgumentParser(description='Check release version information.') -parser.add_argument('--type', choices=['metainfo','news'], default='news') -parser.add_argument('version', help='the version to check for') -parser.add_argument('files', nargs='+', help='files to check') -args = parser.parse_args() - -distroot = os.environ.get('MESON_DIST_ROOT', './') - -try: - for file in args.files: - check_version(args.version, Path(distroot, file), args.type) -except: - sys.exit(1) diff --git a/meson/generate-app-list.py b/meson/generate-app-list.py deleted file mode 100755 index 067c36967..000000000 --- a/meson/generate-app-list.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 - -import argparse - -def read_app_ids(path) -> str: - ids = [] - with open(path, "r") as file: - for line in file: - # strip comments - line, _, _ = line.partition('#'); - line = line.strip() - if len(line) > 0: - ids.append(line) - return ids - -def print_as_array(ids): - mapped_ids = list(map(lambda i: f" '{i}'", ids)) - print('[') - print(',\n'.join(mapped_ids)) - print(']') - -def print_as_pages(ids): - mapped_ids = [] - for i, id in enumerate(ids): - mapped_ids.append(f" '{id}': <{{'position': <{i}>}}>") - - print('[{') - print(',\n'.join(mapped_ids)) - print('}]') - -parser = argparse.ArgumentParser() -parser.add_argument('--pages', action='store_true') -parser.add_argument('file') -args = parser.parse_args() - -ids = read_app_ids(args.file) -if args.pages: - print_as_pages(ids) -else: - print_as_array(ids) diff --git a/meson/generate-stylesheets.py b/meson/generate-stylesheets.py deleted file mode 100644 index 10e65b756..000000000 --- a/meson/generate-stylesheets.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 - -import os -from pathlib import PurePath -import subprocess - -stylesheets = [ - 'data/theme/gnome-shell-high-contrast.css', - 'data/theme/gnome-shell-dark.css', - 'data/theme/gnome-shell-light.css' -] - -sourceroot = os.environ.get('MESON_SOURCE_ROOT') -distroot = os.environ.get('MESON_DIST_ROOT') - -for stylesheet in stylesheets: - stylesheet_path = PurePath(stylesheet) - src = PurePath(sourceroot, stylesheet_path.with_suffix('.scss')) - dst = PurePath(distroot, stylesheet_path) - subprocess.run(['sassc', '-a', src, dst], check=True) diff --git a/subprojects/extensions-app/build-aux/meson/check-version.py b/subprojects/extensions-app/build-aux/meson/check-version.py index fbe6c7458..3f26b4c34 120000 --- a/subprojects/extensions-app/build-aux/meson/check-version.py +++ b/subprojects/extensions-app/build-aux/meson/check-version.py @@ -1 +1 @@ -../../../../meson/check-version.py \ No newline at end of file +../../../../build-aux/check-version.py \ No newline at end of file